package com.juhuixing.common.utils.encryption;

import sun.misc.BASE64Decoder;

import java.io.ByteArrayInputStream;
import java.io.InputStream;

/**
 * 功能描述: base64工具类
 * @author: 刘猛
 * @date: 2019/3/13 13:25
 **/
public class Base64Util {

    /**
     * base64转inputStream
     * @param base64string
     * @return
     */
    public static InputStream BaseToInputStream(String base64string) throws Exception {
        ByteArrayInputStream stream = null;
        try {
            BASE64Decoder decoder = new BASE64Decoder();
            byte[] bytes1 = decoder.decodeBuffer(base64string);
            stream = new ByteArrayInputStream(bytes1);
        } catch (Exception e) {
            throw new Exception("BASE64解密失败",e);
        }
        return stream;
    }

}
